#pragma once

namespace HJR {
	template <class Iterator, class Ref, class Ptr>
	class ReverseIterator {
	public:
		typedef ReverseIterator<Iterator, Ref, Ptr> self;

		ReverseIterator(Iterator it) 
			:_it(it) {}

		Ref operator*() const {
			Iterator tmp = _it;
			return (*--tmp);
		}

		Ptr operator->() const {
			return &(operator*());
		}

		self& operator++() {
			--_it;
			return *this;
		}

		self operator++(int) {
			self tmp(*this);
			--_it;
			return tmp;
		}

		self& operator--() {
			++_it;
			return *this;
		}

		self operator--(int) {
			self tmp(*this);
			++_it;
			return tmp;
		}

		bool operator!=(const self& s) const {
			return _it != s._it;
		}

		bool operator==(const self& s) const {
			return _it == s._it;
		}

	private:
		Iterator _it;
	};
}